825A - Binary Protocol - CodeForces Solution


implementation *1100

Please click on ads to support us..

C++ Code:

// 1677685109140
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define f(i, x, n) for (int i = x; i < n; ++i)
#define rf(i, x, n) for (int i = x; i >= n; --i)
#define fr(i, m) for (auto &i : m)
#define pl pair<long long, long long>
#define vl vector<long long>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rll(v) (v).begin(), (v).end(), greater<ll>()
#define si size()
#define lcm(a, b) ((a * b) / (__gcd(a, b)))

#define time_nhi_hai ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
long double fast_pow(long double a, int p)
{
    long double ret = 1.;
    for (; p; p /= 2, a *= a)
        if (p & 1)
            ret *= a;
    return ret;
}
bool isprime(ll number)
{
    if (number <= 1)
        return false;
    if (number == 2)
        return true;
    if (number % 2 == 0)
        return false;
    int boundary = (int)floor(sqrt(number));
    for (int i = 3; i <= boundary; i += 2)
        if (number % i == 0)
            return false;
    return true;
}
ll power(ll a, ll b)
{
    ll ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (ans * a) % MOD;
        a = (a * a) % MOD;
        b = b / 2;
    }
    return ans;
}
vector<int> Sieve(int n)
{
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));
    for (int p = 2; p * p <= n; p++)
    {
        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    vector<int> vec;
    for (int p = 2; p <= n; p++)
        if (prime[p])
            vec.push_back(p);
    return vec;
}

int main()
{
    time_nhi_hai;

    ll n, m;
    string s;

    cin >> n >> s;

    ll k = 0;
    for (ll i = 0; i < n; i++)
    {
        if (s[i] == '1')
            k++;

        else
        {
            cout << k;
            k = 0;
        }
    }

    cout << k;
}


Comments

Submit
0 Comments
More Questions

734A - Anton and Danik
1300B - Assigning to Classes
1647A - Madoka and Math Dad
710A - King Moves
1131A - Sea Battle
118A - String Task
236A - Boy or Girl
271A - Beautiful Year
520B - Two Buttons
231A - Team
479C - Exams
1030A - In Search of an Easy Problem
158A - Next Round
71A - Way Too Long Words
160A - Twins
1A - Theatre Square
1614B - Divan and a New Project
791A - Bear and Big Brother
1452A - Robot Program
344A - Magnets
96A - Football
702B - Powers of Two
1036A - Function Height
443A - Anton and Letters
1478B - Nezzar and Lucky Number
228A - Is your horseshoe on the other hoof
122A - Lucky Division
1611C - Polycarp Recovers the Permutation
432A - Choosing Teams
758A - Holiday Of Equality